﻿namespace VerEasy.Core.Extensions.Caching.Redis
{
    public interface IRedisCache
    {
        /// <summary>
        /// 异步设置缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="expirationTime"></param>
        /// <returns></returns>
        Task SetAsync(string key, object value, TimeSpan? expirationTime = null);

        /// <summary>
        /// 异步获取缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        Task<string> GetAsync(string key);

        /// <summary>
        /// 异步移除缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        Task RemoveAsync(string key);

        /// <summary>
        /// 异步检查缓存是否存在
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        Task<bool> ExistsAsync(string key);

        /// <summary>
        /// 异步清空缓存
        /// </summary>
        /// <returns></returns>
        Task ClearAsync();

        /// <summary>
        /// 同步设置缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="expirationTime"></param>
        /// <returns></returns>
        void Set(string key, object value, TimeSpan? expirationTime = null);

        /// <summary>
        /// 同步获取缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        string Get(string key);

        /// <summary>
        /// 同步移除缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        void Remove(string key);

        /// <summary>
        /// 同步检查缓存是否存在
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool Exists(string key);

        /// <summary>
        /// 同步清空缓存
        /// </summary>
        /// <returns></returns>
        void Clear();
    }
}